<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>供应商管理系统-{$webname}</title>
    {Common::css("style.css,base.css,extend.css,supplier_back.css")}
    {Common::js("jquery.min.js,common.js,city/jquery.cityselect.js")}
    <link type="text/css" href="/res/js/webuploader/webuploader.css" rel="stylesheet"/>
    <script type="text/javascript" src="/res/js/webuploader/webuploader.min.js"></script>
    <style>
        .shop-upload-logo{
            color: #fff;
            display: inline-block;
            height: 30px;
            line-height: 30px;
            padding: 0 15px;
            font-size: 14px;
            -webkit-border-radius: 3px;
            -moz-border-radius: 3px;
            border-radius: 3px;
            background: #4cc34f;
        }
        .shop-upload-area img{
            width: 334px;
            height: 80px;
            margin-top: 8px;
        }
    </style>
</head>

<body>
    <div class="supplier-main-container">
        <div class="supplier-main-block">
            <div class="account-box">
                <div class="account-tit"><strong class="bt">企业信息</strong></div>
                <form id="usrfrm" table_right=FbRX4t >
                    <div class="account-con">
                        <ul>
                            <li>
                                <strong class="lm">企业logo：</strong>
                                <div class="nr">
                                    <a href="javascript:;" class="shop-upload-logo">+上传图片</a>
                                    <div class="shop-upload-area {if !$userinfo['logo']}hide{/if}">
                                        <img src="{$userinfo['logo']}" id="logo" alt="">
                                    </div>
                                    <div id="file_upload" class="hide">上传</div>
                                    <div class="shop-text-bar">建议上传尺寸167*40，支持jpg、png、gif格式，不超过2M</div>
                                </div>
                            </li>
                            <li>
                                <strong class="lm">企业名称：</strong>
                                <div class="nr"><span class="name">{$userinfo['suppliername']}</span></div>
                            </li>
                            <li>
                                <strong class="lm">法人代表：</strong>
                                <div class="nr"><span class="name">{$userinfo['reprent']}</span></div>
                            </li>
                            <li>
                                <strong class="lm">产品类目：</strong>
                                <div class="nr">
                                    {loop $apply_product $p}
                                    <span class="name">{$p['modulename']}&nbsp;&nbsp;</span>
                                    {/loop}
                                    {if $userinfo['verifystatus']==1}
                                    <a class="revise-mz" href="javascript:;" style=" color:#666; cursor:not-allowed; background:#e0e2e7">等待验证</a>
                                    {elseif $userinfo['verifystatus']==2 || $userinfo['verifystatus']==0}
                                    <a class="revise-mz" href="{$cmsurl}pc/qualify/step">立即验证</a>
                                    {elseif $userinfo['verifystatus']==3}
                                    <a class="revise-mz" href="{$cmsurl}pc/qualify/step">重新验证</a>
                                    {/if}
                                </div>
                            </li>
                            <li>
                                <strong class="lm">分销渠道：</strong>
                                <div class="nr">
                                    {loop $channel_list $p}
                                    <span class="name">{$p['title']}&nbsp;&nbsp;</span>
                                    {/loop}
                                </div>
                            </li>
                            <li>
                                <strong class="lm">公司地址：</strong>
                                <div class="nr">
                                    <input type="text" class="msg-text" name="address" value="{$userinfo['address']}"/>
                                </div>
                            </li>
                            <li>
                                <strong class="lm">联系电话：</strong>
                                <div class="nr">
                                    <input type="text" class="msg-text" name="telephone" value="{$userinfo['telephone']}"/>
                                </div>
                            </li>

                            <li>
                                <strong class="lm">企业微信通知群：</strong>
                                <div class="nr">
                                    <input type="text" class="input-text w500" name="cfg_qywx_admin_url" placeholder="" value="{$cfg_qywx_admin_url}">
                                </div>
                            </li>

                        </ul>
                        <input type="hidden" id="supplierid" name="supplierid" value="{$userinfo['id']}">
                        <input type="hidden" id="frmcode" name="frmcode" value="{$frmcode}"/>
                        <input type="hidden" id="litpic" name="logo" value="{$userinfo['logo']}">
                        <div class="account-save-box"><a href="javascript:;" class="save_btn">保存</a></div>
                    </div>
                </form>
            </div><!-- 账户资料 -->
        </div>
    </div>
    {Common::js("layer/layer.js")}
    <script>
        var SITEURL = '/plugins/supplier/';
        $(function () {
            $("#nav_enterpriseinfo").addClass('on');

            //保存资料
            $(".save_btn").click(function () {
                var frmdata = $("#usrfrm").serialize();

                $.ajax({
                    type: 'post',
                    url: '/supplier/pc/index/ajax_userinfo_save',
                    data: frmdata,
                    dataType: 'json',
                    success: function (data) {
                        if (data.status) {
                            layer.msg("{__('保存成功')}", {
                                icon: 6,
                                time: 1000
                            })
                        } else {
                            layer.msg(data.msg, {icon: 5});
                            return false;
                        }
                    }
                })
            })

            //上传图片.
            $('.shop-upload-logo').click(function () {
                $('.webuploader-container').find('label').trigger('click');
            })
            upload();

            //webuploader上传
            function upload() {
                //正面上传实例
                var uploader = new WebUploader.Uploader({
                    // 选完文件后，是否自动上传。
                    auto: true,
                    // swf文件路径
                    swf: '/res/js/webuploader/Uploader.swf',
                    // 文件接收服务端。
                    server: '/supplier/pc/index/ajax_logo_save',
                    // 选择文件的按钮。可选。
                    pick: '#file_upload',
                    // 只允许选择图片文件。
                    accept: {
                        title: 'Images',
                        extensions: 'gif,jpg,jpeg,bmp,png',
                        mimeTypes: 'image/*'
                    },
                    //上传前压缩项
                    compress: {
                        width: 1600,
                        height: 1600,
                        // 图片质量。仅仅有type为`image/jpeg`的时候才有效。
                        quality: 90,
                        // 是否同意放大，假设想要生成小图的时候不失真。此选项应该设置为false.
                        allowMagnify: false,
                        // 是否同意裁剪。
                        crop: false,
                        // 是否保留头部meta信息。
                        preserveHeaders: true,
                        // 假设发现压缩后文件大小比原来还大，则使用原来图片
                        // 此属性可能会影响图片自己主动纠正功能
                        noCompressIfLarger: false,
                        // 单位字节，假设图片大小小于此值。不会採用压缩。(大于2M压缩)
                        compressSize: 1024 * 1024 * 2
                    }
                });
                // 文件上传过程中创建进度条实时显示。
                uploader.on('uploadProgress', function (file, percentage) {

                });
                // 文件上传成功
                uploader.on('uploadSuccess', function (file, data) {
                    //如果上传成功
                    if (data.status) {
                        $('#logo').attr('src', data.litpic);
                        $('#litpic').val(data.litpic);
                        $('.shop-upload-area').show();
                        layer.msg('图片上传成功，请点击下方“保存”按钮替换新的logo图片。');
                    } else {
                        $.layer({
                            type: 1,
                            icon: 2,
                            text: data.msg,
                            time: 1000
                        });
                    }
                });
                // 完成上传完了，成功或者失败，先删除进度条。
                uploader.on('uploadComplete', function (file) {
                    //                $.layer.close();
                });
            }
        })
    </script>
</body>
</html>
